#include "marketapp.h"

namespace XTrade {

	MarketApp theApp;

	MarketApp::MarketApp()
	{

	}

	bool MarketApp::start(int argc, char* argv[])
	{
		XBoostApp::init(argv[argc - 1], XBoost::XML_FLAG_JSON_FILE);
		boost::property_tree::ptree & app_cfg = cfg();
		auto opt_platform = app_cfg.get_child_optional("platform");
		auto opt_server = app_cfg.get_child_optional("server");
		ASSERT(opt_platform && opt_server);
		if (platform_.start(opt_platform.get())) {
			return server_.start(opt_server.get());
		}
		return false;
	}

	void MarketApp::stop()
	{
		server_.stop();
		platform_.stop();
		term();
	}
}
